use utils::ufmt;


pub mod proto;

#[derive(Debug, ufmt::derive::uDebug)]
pub enum Error {
    NoFindStart,
    CheckSum,
    Invalid,
}

pub struct Proto {
    //pub cmd1: u8, 0xC1
    pub cmd2: u8,
    pub data1: u8,
    pub data2: u8,
}

pub unsafe fn check_sum(ptr: *const u8, len: usize) -> u8 {
    let mut v: u8 = 0;
    for i in 0..len {
        v = v.wrapping_add(*ptr.add(i));
    }
    v
}

